package cn.itcast.star.graph.core.advice;

import cn.itcast.star.graph.core.dto.common.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@RestControllerAdvice
@Slf4j
public class CommonExceptionAdvice {

    @ExceptionHandler(Exception.class)
    public ResponseEntity<Result<Object>> exception(Exception e) {
        log.info("全局异常处理器处理异常：", e);
        return ResponseEntity.status(HttpStatus.OK.value()).body(Result.error(e.getLocalizedMessage()));
    }
}
